//
//  HMMainViewController.swift
//  HMWeiBo001
//
//  Created by zzl491263867 on 16/4/7.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class HMMainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        addchildviewcontrollers()
       
    }
    //MARK
    //private只有在当前文件才可以访问该方法
    private func addchildviewcontrollers(){

    addchildViewController(HMHomeTableViewController(), title: "首页", imageName: "tabbar_home")
    addchildViewController(HMHomeTableViewController(), title: "消息", imageName: "tabbar_message_center")
    addchildViewController(HMHomeTableViewController(), title: "发现", imageName: "tabbar_discover")
    addchildViewController(HMHomeTableViewController(), title: "我", imageName: "tabbar_profile")
    }
    private func addchildViewController(vc: UIViewController,title:String,imageName:String){
        vc.tabBarItem.title = title
//        vc.navigationItem.title = title
        vc.title = title
        vc.tabBarItem.image = UIImage(named: imageName)
        vc.tabBarItem.selectedImage = UIImage(named: imageName + "_selected")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
//        vc.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.orangeColor()], forState: .Selected)
        tabBar.tintColor = UIColor.redColor()
        let nav = UINavigationController(rootViewController: vc)
        addChildViewController(nav)
    }
}